/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Others;

import db_interaction.NewHibernateUtil;
import db_interaction.Utilizador;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author Nuno
 */
public class seachUsers {

    Utilizador users = null;

    public Utilizador SEARCH(String Email) {

        try {
            Session s = NewHibernateUtil.getSessionFactory();


            s.beginTransaction();

            Query q = s.createQuery("from Utilizador where Utilizador_email like'%" + Email + "%'");
            users = (Utilizador) q.list().get(0);

            s.getTransaction().commit();


            return users;

        } catch (Exception e) {
            return null;
        }
    }
}
